import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        port: 8010,
        proxy: {
            '/api': {
                target: 'http://localhost:8003',//本地地址
                //target: 'http://162.14.78.4:8003',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
            // '/ali': {
            //     //配置目标服务器地址
            //     //target: 'http://localhost:8003',
            //     target: 'http://162.14.78.4:8003',
            //     //允许跨域
            //     changeOrigin: true,
            //     //url重写
            //     rewrite: (path) => path.replace(/^\/ali/, '')
            // },
            '/picture': {
                target:'http://localhost:8004',//本地地址
                //target: 'http://43.136.178.163:8004',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/picture/, '')
            },
            '/pic': {
                target: 'http://162.14.78.4:8003',//远程地址
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/pic/, '')
            }
        },


    }
})
